import java.util.Arrays;
import java.util.Random;

/**
 *  模拟产生一个双色球的中奖号码
 * 红球 1-33: 6 不重复的,最终结果从小到大的
 * 蓝球 1-16: 1 nextInt(16)+1
 */
public class Demo01 {
    public static void main(String[] args) {
        int[] red=new int[6];
        int bull=0;
        Integer[] redBalls = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,
                18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33};
        Random r = new Random();
        for(int i=0;i<red.length;i++) {
            int index = 0;
            while(true) {
                index = r.nextInt(33);
                if(redBalls[index]!=-1) {
                    red[i] = redBalls[index];
                    redBalls[index] = -1;
                    break;
                }
            }
        }
        for (int i = 0; i < red.length-1; i++) {
            for (int j=0;j< red.length-i-1;j++){
                if(red[j]>red[j+1]){
                    int temp=red[j+1];
                    red[j+1]=red[j];
                    red[j]=temp;
                }
            }
        }
        bull = r.nextInt(16)+1;
        System.out.println("红球号码:" + Arrays.toString(red) + "蓝球号码" + bull);
    }
}
